<?php
namespace App\Observers;

use App\Models\Master;
use App\Services\ISessionService;

/**
 * Created by PhpStorm.
 * User: ownfi
 * Date: 2017-03-29
 * Time: 17:01
 */
class MasterObserver
{

    private $sessionService;

    public function __construct(ISessionService $sessionService)
    {
        $this->sessionService = $sessionService;
    }

    public function updated(Master $user)
    {
        /**
         * 更新当前用户session
         */
        if (getCurrentUserid() == $user->id){
            $this->sessionService->setCurrentUser($user);
        }
    }

}